package cn.yunhe.controller;

import cn.yunhe.entity.Class;
import cn.yunhe.entity.Dept;
import cn.yunhe.entity.Prof;
import cn.yunhe.services.IClassServices;
import cn.yunhe.services.IProfServices;
import cn.yunhe.services.ITeacherServices;
import com.github.pagehelper.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/6/6.
 */
@RestController
@RequestMapping("/teacher")
public class TeacherController {
    @Resource
    private ITeacherServices teacherServices;
    @Resource
    private IProfServices profServicesImpl;
    @Resource
    private IClassServices classServices;

    @RequestMapping("/student")
    public Map<String,Object> getController(int pageNum, int pageSize, Class cla){
        Map<String,Object> map=new HashMap<>();
        map.put("pageNum",pageNum);
        map.put("pageSize",pageSize);
        map.put("cla",cla);
        List<Class> list=classServices.getAllClassServices(cla.getProf());
        Page page=teacherServices.getStudent(map);
        map.put("page",page);
        map.put("totalPage",page.getPages());
        map.put("class",list);
        return map;
    }
    @RequestMapping("/prof")
    public ModelAndView getAllProf(){
        Dept dept=new Dept();
        dept.setDept_id(1);
        List<Prof> list=profServicesImpl.getAllProfServices(dept);
        ModelAndView modelAndView=new ModelAndView("ftl/teacher");
        modelAndView.addObject("prof",list);
        System.out.println(list);
        return modelAndView;
    }
}
